var rule = {
    title: '种子音乐',
    host: 'https://www.zz123.com',
    homeUrl: '/list/mszm.htm?page=1',
    url: '/fyclass.htm?page=fypage',
    searchable: 2,
    quickSearch: 0,
    headers: {
        'User-Agent': 'MOBILE_UA',
        'referer': 'https://www.zz123.com/',
    },
    class_parse: '.aside-menu-list.channel&&[href*=list];a&&Text;a&&href;.(list.*).htm',
    play_parse: true,
    lazy: `js:
        input = input.replace(/play\\/(\\w+)\\.htm/, 'ajax/?act=songinfo&id=$1&lang=');
        log('Transformed URL: ' + input);
        let response = request(input);
        log('AJAX response: ' + response);
        let data = JSON.parse(response);
        if (data && data.data) {
            let mp3 = data.data.mp3;
            let lyrics = data.data.lyrics || '';
            log('MP3 URL: ' + mp3);
            log('Lyrics: ' + lyrics);
            input = {
                jx: 0,
                url: mp3,
                parse: 1,
                header: JSON.stringify({ Referer: 'https://www.zz123.com/' }),
                lyrics: lyrics
            };
        } else {
            log('MP3 URL or lyrics not found');
        }
    `,
    limit: 6,
    推荐: "*",
    一级: '.mobile-list&&.mobile-list-item;.songname&&Text;.lazyload&&data-src;.authorname&&Text;a&&href',
    二级: '*',
    searchUrl: '/ajax/?act=search&key=**&lang=',
    detailUrl: '/play/fyid.html',
    搜索: 'json:data;mname;pic;sname;id',
};

// 代码用于解析歌词和播放音乐时同步显示歌词
function playWithLyrics(input) {
    let audio = new Audio(input.url);
    let lyrics = input.lyrics;
    let lyricsContainer = document.getElementById('lyrics-container'); // 假设有一个元素用于显示歌词

    audio.ontimeupdate = function() {
        let currentTime = audio.currentTime;
        displayLyrics(lyrics, currentTime, lyricsContainer);
    };

    audio.play();
}

function displayLyrics(lyrics, currentTime, container) {
    let lines = lyrics.split('\\n');
    let currentLyrics = '';
    for (let line of lines) {
        let time = parseLyricsTime(line);
        if (time && currentTime >= time) {
            currentLyrics = line.replace(/\\[.*?\\]/g, ''); // 移除时间戳
        }
    }
    container.innerText = currentLyrics;
}

function parseLyricsTime(line) {
    let match = line.match(/\\[(\\d+):(\\d+)\\.(\\d+)\\]/);
    if (match) {
        let minutes = parseInt(match[1]);
        let seconds = parseInt(match[2]);
        let milliseconds = parseInt(match[3]);
        return minutes * 60 + seconds + milliseconds / 1000;
    }
    return null;
}
